package fr.umlv.m2.jee.gwt.spring.web.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import fr.umlv.m2.jee.gwt.spring.service.client.author.IAuthorService;
import fr.umlv.m2.jee.gwt.spring.service.client.author.IAuthorServiceAsync;

/**
 * Created by IntelliJ IDEA.
 * User: gloyaute
 * Date: 06 26 2011
 * Time: 16:55:39
 * To change this template use File | Settings | File Templates.
 */
public class GwtRpcSpringSample implements EntryPoint {
    private final IAuthorServiceAsync testService = GWT.create(IAuthorService.class);

    @Override
    public void onModuleLoad() {

        Button button = new Button("Click me");

        // We can add style names
        button.addStyleName("pc-template-btn");

        VerticalPanel vPanel = new VerticalPanel();
        vPanel.setWidth("100%");
        vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
        vPanel.add(button);

        // Add table and button to the RootPanel
        // RootPanel.get().add(vPanel);
        RootLayoutPanel.get().add(vPanel);
        RootPanel.get().add(RootLayoutPanel.get());

        testService.getAuthor(new AsyncCallback< String >() {

            @Override
            public void onFailure(Throwable throwable) {
                System.out.println("Failure");
            }

            @Override
            public void onSuccess(String s) {
                System.out.println("success");
            }
        });
    }
}

